﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace Congducsan
{
    public partial class frmCaoD : Form
    {
        public frmCaoD()
        {
            InitializeComponent();
        }

        private void frmCaoD_FormClosing(object sender, FormClosingEventArgs e)
        {
            DradApplication.DradApp.FormMain.Show();
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmCaoD_Resize(object sender, EventArgs e)
        {
            this.Size = new Size(493, 339);
        }

        private void frmCaoD_Load(object sender, EventArgs e)
        {
            loadSettingReg();
        }
        private void saveSettingReg()
        {
            RegistryKey regKey = Registry.CurrentUser;
            regKey = regKey.CreateSubKey("Software\\HaithanhSoft\\Drad2012\\Congducsan");
            string Values = "";
            Values = txtCaodG .Text;//0
            Values = Values +"\t"+ txtGa .Text;//1
            Values = Values +"\t"+ txtKtMuiten .Text;//2
            Values = Values +"\t"+ txtCaochu .Text;//3
            Values = Values +"\t"+ txtCaoGhichu .Text;//4
            Values = Values +"\t"+ Option1.Checked.ToString();//5
            Values = Values +"\t"+ Option2.Checked.ToString();//6
            Values = Values +"\t"+ Option3.Checked.ToString();//7
            Values = Values +"\t"+ Option4.Checked.ToString();//8
            Values = Values +"\t"+ Option5.Checked.ToString();//9
            regKey.SetValue("TsCd", Values);
            regKey.Close();
        }
        private void loadSettingReg()
        {
            RegistryKey regKey = Registry.CurrentUser;
            RegistryKey testKey = regKey.OpenSubKey("Software\\HaithanhSoft\\Drad2012\\Congducsan");
            if (testKey != null)
            {
                regKey = regKey.CreateSubKey("Software\\HaithanhSoft\\Drad2012\\Congducsan");
                string str = regKey.GetValue("TsCd").ToString();
                string[] STR = str.Split('\t');
                int i = 0;
                txtCaodG.Text=STR[i++];//0
                txtGa.Text = STR[i++];//1
                txtKtMuiten.Text = STR[i++];//2
                txtCaochu.Text = STR[i++];//3
                txtCaoGhichu.Text = STR[i++];//4
                Option1.Checked = bool.Parse(STR[i++]);//5
                Option2.Checked = bool.Parse(STR[i++]);//6
                Option3.Checked = bool.Parse(STR[i++]);//7
                Option4.Checked = bool.Parse(STR[i++]);//8
                Option5.Checked = bool.Parse(STR[i++]);//9
                regKey.Close();
            }
        }

        private void frmCaoD_FormClosed(object sender, FormClosedEventArgs e)
        {
            saveSettingReg();
        }

        private void OK_Click(object sender, EventArgs e)
        {

        }
    }
}
